#!/usr/bin/env sh

set -eu

: ${CONTINUOUS_INTEGRATION=}
: ${DOCKER_BUILDKIT=}

progressFlag=""
if [ "$CONTINUOUS_INTEGRATION" = "true" ]; then progressFlag="--progress=plain"; fi

cacheOnlyFlag=""
if ! docker build --help 2>&1 | grep buildx >/dev/null; then cacheOnlyFlag="-o type=cacheonly"; fi

export DOCKER_BUILDKIT=1
docker build $progressFlag $cacheOnlyFlag -f ./hack/dockerfiles/shfmt.Dockerfile --target validate .
